package cc.decat.escript.codegen;

import cc.decat.escript.ir.ChunkNode;
import cc.decat.escript.ir.CodegenVisitorImpl;
import cc.decat.escript.runtime.Context;
import cc.decat.escript.runtime.GlobalContext;

public class Compiler {

    private final GlobalContext globalContext;
    private final Codegen codegen;

    public Compiler(GlobalContext globalContext) {
        this.globalContext = globalContext;
        this.codegen = new Codegen(globalContext);
    }

    public FunctionGenerate compile(ChunkNode chunkNode) {
        new CodegenVisitorImpl(codegen).visit(chunkNode);
        return codegen.getChunkFunctionGenerate();
    }
}
